<?php

class DataSet {
	var $id;
	var $inkURL;
	var $title;
	var $subTitle;
	var $description;
	var $imagePath;
	var $dataDir;
	
	
	function insert(&$db, $inkUrl) {
		$url = sqlEscape($inkUrl);
		$sql = "INSERT INTO key_data 
			(inkUrl) 
		VALUES('$inkUrl')";  
		
		$this->id = $db->doInsert($sql);
		return $this->id;
	}	
	
	function findById(&$db, $id) {
		$sql = "SELECT * from key_data where id = '$id'";
		$user =& $db->selectOne($sql, new DataSet());
		return $user;
	}
	
	function findByInkUrl(&$db, $inkUrl) {
		$sql = "SELECT * from key_data where inkUrl = '$inkUrl'";
		$user =& $db->selectOne($sql, new DataSet());
		return $user;
	}	
	
	function dbLoadCallback(&$dbRow) {
		if ( !$dbRow ) {
			return;
		}
		if ( isset($dbRow['id']) ) {		
			$this->id = $dbRow['id'];
		}	
		if ( isset($dbRow['inkUrl']) ) {
			$this->inkURL = $dbRow['inkUrl'];
		} else {
			$this->inkURL = '';
		}
		if ( isset($dbRow['title']) ) {
			$this->title = $dbRow['title'];
		} else {
			$this->title = '';
		}
		if ( isset($dbRow['subTitle']) ) {
			$this->subTitle = $dbRow['subTitle'];
		} else {
			$this->subTitle = '';
		}
		if ( isset($dbRow['description']) ) {
			$this->description = $dbRow['description'];
		} else {
			$this->description = '';
		}
		if ( isset($dbRow['imagePath']) ) {
			$this->imagePath = $dbRow['imagePath'];
		} else {
			$this->imagePath = '';
		}
		if ( isset($dbRow['dataDir']) ) {
			$this->dataDir = $dbRow['dataDir'];
		} else {
			$this->dataDir = '';
		}		
	}	
	
	function &newInstance() {
		$inst = new DataSet();
		return $inst;
	}
}

?>